//
//  SalesGoodsListTableViewCell.m
//  JiuJiuShangCheng
//
//  Created by jiujiukeji on 2018/7/6.
//  Copyright © 2018年 jiujiukeji. All rights reserved.
//

#import "SalesGoodsListTableViewCell.h"

@implementation SalesGoodsListTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUpUI];
    }
    return self;
}
- (void)setUpUI
{
    WeakSelf
    self.goodsImg = [[UIImageView alloc] init];
    _goodsImg.image = UIImageNamed(@"salesGoods");
    [self addSubview:_goodsImg];
    [_goodsImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(rateWidth(30));
        make.centerY.equalTo(self);
        make.size.mas_offset(CGSizeMake(rateHeight(150), rateHeight(150)));
    }];
    
    self.goodsTitleLB = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0x323232) fontSize:15];
    _goodsTitleLB.numberOfLines = 0;
    [self addSubview:self.goodsTitleLB];
    [_goodsTitleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.goodsImg.mas_right).offset(rateWidth(20));
        make.width.lessThanOrEqualTo(@(rateWidth(490)));
        make.top.equalTo(weakSelf.goodsImg).offset(rateHeight(0));
        make.height.mas_lessThanOrEqualTo(@(rateHeight(100)));
    }];
    
    
    // 倒计时
    self.jieShuLB = [UILabel labelWithText:@"距离结束：" textColor:[UIColor darkGrayColor] fontSize:11];
    [self.jieShuLB sizeToFit];
    [self addSubview:self.jieShuLB];
    [self.jieShuLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.goodsTitleLB);
        make.top.equalTo(weakSelf.goodsTitleLB.mas_bottom).offset(rateHeight(10));
    }];
    
    HSFTimeDownConfig *config = [[HSFTimeDownConfig alloc]init];
    self.timeLabel_hsf = [[HSFTimeDownView alloc] initWityFrame:CGRectMake(self.frame.size.width * .5 - 100, 500, 200, 20) config:config timeChange:^(NSInteger time) {
        // NSLog(@"hsf===%ld",(long)time);
    } timeEnd:^{
        
    }];
    [self addSubview:self.timeLabel_hsf];
    [self.timeLabel_hsf mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.jieShuLB.mas_right);
        make.centerY.equalTo(weakSelf.jieShuLB);
        make.size.mas_offset(CGSizeMake(150, 20));
    }];
    self.jieShuLB.hidden = YES;
    self.timeLabel_hsf.hidden = YES;
    
    self.priceLB = [UILabel labelWithText:@"￥0.00" textColor:UIColorFromRGB(0xf55555) fontSize:15];
    [_priceLB sizeToFit];
    [self addSubview:_priceLB];
    [_priceLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.goodsTitleLB);
        make.bottom.equalTo(weakSelf.goodsImg).offset(rateHeight(10));
    }];
    
    self.stateBtn = [UIButton buttonWithTitle:@"点击查看" fontSize:13 titleColor:UIColorFromRGB(0x323232) background:UIColorFromRGB(0xf5f5f5) cornerRadius:3];
    [self addSubview:_stateBtn];
    [_stateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-rateWidth(30));
        make.size.mas_offset(CGSizeMake(rateWidth(160), rateHeight(55)));
        make.centerY.equalTo(weakSelf.priceLB);
    }];
    
    self.line = [[UIView alloc] init];
    _line.backgroundColor = globalGray;
    [self addSubview:_line];
    [_line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self);
        make.height.equalTo(@(rateHeight(1)));
    }];
    
}

@end
